package com.talos.ums.enums;

import org.springframework.util.StringUtils;

//组织机构类型
public enum OrganizationTypeEnum {


    DEPARTMENT("DEPARTMENT", "部门"),
    COMPANY("COMPANY", "公司");

    String code;
    String message;

    OrganizationTypeEnum(String code, String message) {
        this.code = code;
        this.message = message;
    }


    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }



    public static OrganizationTypeEnum getByCode(String code) {
        if (StringUtils.isEmpty(code)) {
            return null;
        }

        for (OrganizationTypeEnum resourceTypeEnum : OrganizationTypeEnum.values()) {
            if (code.equals(resourceTypeEnum.getCode())) {
                return resourceTypeEnum;
            }
        }

        return null;
    }

    public static OrganizationTypeEnum getByMessage(String message) {
        if (StringUtils.isEmpty(message)) {
            return null;
        }

        for (OrganizationTypeEnum resourceTypeEnum : OrganizationTypeEnum.values()) {
            if (message.equals(resourceTypeEnum.getMessage())) {
                return resourceTypeEnum;
            }
        }

        return null;
    }

}
